package com.yunduo.aspect.log;


import com.yunduo.common.RetunData.CommonReturn;
import com.yunduo.common.RetunData.statuscode.impl.ServerCode;
import com.yunduo.common.RetunData.statuscode.impl.UserCode;
import com.yunduo.entity.vo.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.SetOperations;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 登录业务日志 切面
 */
@Aspect
@Slf4j
@Component
public class UserLogAspect {

    //用户登录记录日志日志
    @AfterReturning(value = "execution(* com.yunduo.controller.AuthController.login(..))",returning = "result")
    public void loginLog(JoinPoint point, Object result) throws Throwable {
        LoginUser user = (LoginUser)point.getArgs()[0];
        CommonReturn commonReturn = (CommonReturn)result;
        String message = commonReturn.getMessage();
        //日志打印
        log.info(user.getName()+" "+message);
    }

}
